<template>
  <button @click="insertTestData">导入测试数据</button>
</template>

<script>
import { useResumeStore } from '../store/resume';

export default {
  name: 'dataInsertBtn',
  methods: {
    async insertTestData() {
      const testData = {
        basic: {
          name: "张小明",
          phone: "13800138000",
          email: "xiaoming.zhang@example.com",
          gender: "male",
          status: "待业"
        },
        education: [
          {
            id: 1,
            school: "清华大学",
            college: "计算机科学与技术系",
            major: "软件工程",
            degree: "硕士",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-25T16:00:00.000Z"],
            gradeType: "gpa",
            grade: "3.6",
            courses: [{
              name: "分布式系统",
              score: 89,
              },{
              name: "机器学习",
              score: 90,
            }],
          },
          {
            id: 2,
            school: "上海交通大学",
            college: "电子信息学院", 
            major: "计算机应用",
            degree: "本科",
            duration: ["2025-03-02T16:00:00.000Z", "2025-04-24T16:00:00.000Z"],
            gradeType: "score",
            grade: "89.5",
            courses: [{
              name: "数据结构",
              score: 89,
              },{
              name: "操作系统",
              score: 90,
            }],
          }
        ],
        workExperience: [
          {
            id: 1,
            company: "阿里巴巴集团",
            position: "高级前端工程师",
            employmentType: "full-time",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-25T16:00:00.000Z"],
            description: "负责淘宝核心前端架构开发"
          },
          {
            id: 2,
            company: "字节跳动",
            position: "前端开发工程师",
            employmentType: "实习",
            duration: ["2025-03-01T16:00:00.000Z", "2025-04-25T16:00:00.000Z"], 
            description: "参与抖音国际版前端开发"
          }
        ],
        projects: [
          {
            id: 1,
            name: "智能简历解析系统",
            role: "项目负责人",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-23T16:00:00.000Z"],
            description: "基于NLP的简历智能解析平台"
          },
          {
            id: 2,
            name: "电商大数据可视化",
            role: "核心开发",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-17T16:00:00.000Z"],
            description: "千万级数据的实时可视化展示"
          },
          {
            id: 3,
            name: "移动端OA系统",
            role: "前端架构",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-18T16:00:00.000Z"],
            description: "企业级移动办公平台开发"
          }
        ],
        skills: [
          {
            id: 1,
            name: "Vue3",
            proficiency: "精通"
          },
          {
            id: 2,
            name: "TypeScript",
            proficiency: "熟练"
          },
          {
            id: 3, 
            name: "Node.js",
            proficiency: "掌握"
          }
        ],
        campusExperience: [
          {
            id: 1,
            organization: "微软学生俱乐部",
            position: "技术部长",
            type: "学术",
            duration: ["2025-03-03T16:00:00.000Z", "2025-04-15T16:00:00.000Z"],
            description: "组织技术讲座和编程比赛"
          }
        ],
        jobObjectives: [
          {
            id: 1,
            position: "前端架构师",
            salary: "30-50k"
          }
        ],
        awards: [
          {
            id: 1,
            name: "国家奖学金",
            date: "2025-03-05",
            level: "国家级",
            organization: "教育部",
            files: []
          },
          {
            id: 2,
            name: "ACM竞赛金奖",
            date: "2025-03-19", 
            level: "省级",
            organization: "计算机学会",
            files: []
          }
        ]
      };

      try {
        const resumeStore = useResumeStore();
        await resumeStore.saveProfile(testData);
        alert('测试数据导入成功');
      } catch (error) {
        console.error('导入测试数据失败:', error);
        alert('导入测试数据失败');
      }
    }
  }
};
</script>

<style scoped>
button {
  padding: 8px 16px;
  background-color: #1890ff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #40a9ff;
}
</style>
